Iterators have become popular features in programming languages. Iterators provide an abstraction between a particular data structure and the functions that use them. Thus, a function may use values contained or exposed by an iterator without knowing how they are stored, maintained, or calculated by an underlying data structure.
The language integrated query (“LINQ”) programming language extensions provide a further abstraction where developers may specify computations over data sets using declarative queries. These declarative queries are typically implemented using one or more iterators and may similarly be used without knowing how the underlying queries are implemented.
While such declarative queries and iterators are popular because they greatly simplify the code generated by a programmer, their usage may lead to excessive performance penalties. Many programming languages use virtual function calls to implement iterators and/or declarative queries which are computationally expensive. Moreover, declarative queries are often nested, resulting in even greater performance penalties.